//
//  CardRecordCell.m
//  MRBang
//
//  Created by 铅笔 on 16/4/20.
//  Copyright © 2016年 杭州易网新科技. All rights reserved.
//

#import "CardRecordCell.h"

@interface CardRecordCell ()

@property (nonatomic,strong) UIView *view_topBG;
@property (nonatomic,strong) UIImageView *imageView_icon;
@property (nonatomic,strong) UILabel *label_bankName;//银行名
@property (nonatomic,strong) UILabel *label_detailText;//详细小字
@property (nonatomic,strong) UILabel *label_status;//状态

@property (nonatomic,strong) UIButton *button_right;//右侧按钮

@end

@implementation CardRecordCell


- (instancetype) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{

    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self initWithCardRecordCellSubviews];
    }
    return self;
}

- (void) initWithCardRecordCellSubviews
{

    // 头部
    self.view_topBG = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 80)];
    [self addSubview:self.view_topBG];
    
    //imageview
    self.imageView_icon = [[UIImageView alloc] initWithFrame:CGRectMake(48*PROPORTION_WIDTH, 15, 188*PROPORTION_WIDTH, 120*PROPORTION_WIDTH)];
    [self.view_topBG addSubview:self.imageView_icon];
    self.imageView_icon.layer.cornerRadius = 5.0;
    self.imageView_icon.clipsToBounds = YES;
    
    //银行名
    self.label_bankName = [[UILabel alloc] initWithFrame:CGRectMake(self.imageView_icon.frame.size.width+self.imageView_icon.frame.origin.x+10, self.imageView_icon.frame.origin.y+5, kScreenWidth-self.imageView_icon.frame.size.width-self.imageView_icon.frame.origin.x-80, 20)];
    [self.view_topBG addSubview:self.self.label_bankName];
    self.label_bankName.font = [UIFont systemFontOfSize:24*PROPORTION_WIDTH];
    self.label_bankName.textColor = [BaseViewController colorWithHexString:@"#010101"];
    
    //detail
    self.label_detailText = [[UILabel alloc] initWithFrame:CGRectMake(self.label_bankName.frame.origin.x, self.label_bankName.frame.origin.y+self.label_bankName.frame.size.height, self.label_bankName.frame.size.width, 30)];
    [self.view_topBG addSubview:self.self.label_detailText];
    self.label_detailText.font = [UIFont systemFontOfSize:18*PROPORTION_WIDTH];
    self.label_detailText.textColor = [BaseViewController colorWithHexString:@"#666666"];
    
    //uilabel
    self.label_status =  [[UILabel alloc] initWithFrame:CGRectMake(kScreenWidth-130*PROPORTION_WIDTH, self.label_bankName.frame.origin.y+self.label_bankName.frame.size.height-8, 130*PROPORTION_WIDTH,20*2*PROPORTION_WIDTH)];
    [self.view_topBG addSubview:self.label_status];
    self.label_status.font = [UIFont systemFontOfSize:22*PROPORTION_WIDTH];
}

/**
 *赋值的过程
 */
- (void) initWithCarRecordModel:(CardRecordModel *)modelValue
{

    self.label_status.frame =  CGRectMake(kScreenWidth-130*PROPORTION_WIDTH, self.label_bankName.frame.origin.y+self.label_bankName.frame.size.height-8, 130*PROPORTION_WIDTH,20*2*PROPORTION_WIDTH);
    
    [self.imageView_icon sd_setImageWithURL:[NSURL URLWithString:modelValue.cardimg] placeholderImage:nil];
    self.label_bankName.text = modelValue.cardname;
    self.label_detailText.text = @"匹配淘宝Vip等级,尊享Vip权益";
    
    if ([modelValue.status intValue]==0) {
        self.label_status.textColor = [BaseViewController colorWithHexString:@"#b3b3b3"];
        self.label_status.text = @"审核失败";
    }
    if ([modelValue.status intValue]==1) {
        self.label_status.textColor = [BaseViewController colorWithHexString:@"#ff7670"];
        self.label_status.text = @"办理中";
    }
    if ([modelValue.status intValue]==2) {
        self.label_status.textColor = [BaseViewController colorWithHexString:@"#ff7670"];
        self.label_status.text = @"正在审核";
    }
    
    self.button_right.hidden = YES;
    
    if ([modelValue.status intValue]==3) {
        
        self.label_status.frame = CGRectMake(kScreenWidth-170*PROPORTION_WIDTH, 75*PROPORTION_WIDTH, 67*PROPORTION_WIDTH,23*PROPORTION_WIDTH);

        self.label_status.textColor = [BaseViewController colorWithHexString:@"#010101"];
        self.label_status.text = @"已放卡";
        
        self.button_right = [[UIButton alloc] initWithFrame:CGRectMake(10*PROPORTION_WIDTH+self.label_status.right, 68*PROPORTION_WIDTH, 68*PROPORTION_WIDTH, 45*PROPORTION_WIDTH)];
        [self addSubview:self.button_right];

        [self.button_right setTitle:@"激活" forState:UIControlStateNormal];
        [self.button_right setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        
        [self.button_right.titleLabel setFont:[UIFont systemFontOfSize:Font_SIZE_22]];
        self.button_right.backgroundColor = COLOR_BUTTON;
        self.button_right.layer.cornerRadius = 3.0;
        self.button_right.clipsToBounds = YES;
        
        [self.button_right addTarget:self action:@selector(activationAction) forControlEvents:UIControlEventTouchUpInside];
    }
    
    
}

//激活
- (void) activationAction
{

    NSLog(@"激活");

}

- (void)awakeFromNib {
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];


}

@end
